tools/ocaml/evtchn: OCaml 5 support, fix potential resource leak
authorEdwin Török <edvin.torok@citrix.com>
Tue, 18 Jan 2022 15:04:48 +0000 (15:04 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 20 Dec 2022 13:13:40 +0000 (13:13 +0000)
commitd11528a993f80c6a86f4cb0c30578c026348e3e4
tree75bab1ed2ff6c31df70cd2d71ee94cb30ccdfc53
parent2e8d7a08bcd111fe21569e9ace1a047df76da949
tools/ocaml/evtchn: OCaml 5 support, fix potential resource leak

There is no binding for xenevtchn_close().  In principle, this is a resource
leak, but the typical usage is as a singleton that lives for the lifetime of
the program.

Ocaml 5 no longer permits storing a naked C pointer in an Ocaml value.

Therefore, use a Custom block.  This allows us to use the finaliser callback
to call xenevtchn_close(), if the Ocaml object goes out of scope.

Signed-off-by: Edwin Török <edvin.torok@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
(cherry picked from commit 22d5affdf0cecfa6faae46fbaec68b8018835220)
tools/ocaml/libs/eventchn/xeneventchn_stubs.c